<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>11_高阶函数_函数柯里化</title>
</head>

<body>
    <div id="test"></div>
    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <script type="text/babel">
        //1 创建类式组件
        class Login extends React.Component {
            state = {
                username: '',
                password: ''
            }
            handleSubmit = (event) => {
                event.preventDefault()
                const { username, password } = this.state
                alert(`username:${username}  password:${password}`)

            }
            saveFormData = (fieldName, value) => {
                this.setState({ [fieldName]: value })
            }
            render() {
                return (
                    <form onSubmit={this.handleSubmit}>
                        账户：<input name='username' type="text" onChange={event => this.saveFormData('username', event.target.value)} />
                        <br />
                        密码：<input name='password' type="password" onChange={event => this.saveFormData('password', event.target.value)} />
                        <br />
                        <button>点击</button>
                    </form>
                )
            }

        }
        //2 渲染组件到页面 
        ReactDOM.render(<Login />, document.getElementById('test'))

    </script>
</body>

</html>